package com.hongtech.modules.app.controller;

import com.hongtech.common.bean.AjaxResultVo;
import com.hongtech.modules.app.annotation.AppLogin;
import com.hongtech.modules.app.annotation.AppLoginUser;
import com.hongtech.modules.app.entity.UserEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * APP测试接口
 */
@RestController
@RequestMapping("/app")
@Api(tags = "APP测试接口")
public class AppTestController {

    @AppLogin
    @GetMapping("userInfo")
    @ApiOperation("获取用户信息")
    public AjaxResultVo userInfo(@AppLoginUser UserEntity user){
        return AjaxResultVo.success().put("user", user);
    }

    @AppLogin
    @GetMapping("userId")
    @ApiOperation("获取用户ID")
    public AjaxResultVo userInfo(@RequestAttribute("userId") Integer userId){
        return AjaxResultVo.success().put("userId", userId);
    }

    @GetMapping("notToken")
    @ApiOperation("忽略Token验证测试")
    public AjaxResultVo notToken(){
        return AjaxResultVo.success().put("msg", "无需token也能访问。。。");
    }

}
